package com.spddr.pmos.domain;

import java.util.Arrays;

public enum Season {
	All(0, new int[] {}), //
	Dry(1, new int[] { 1, 2, 3, 11, 12 }), //
	Level(2, new int[] { 4, 10 }), //
	Rainy(3, new int[] { 5, 6, 7, 8, 9 });

	public final int id;
	public final int months[];

	private Season(int id, int[] months) {
		this.id = id;
		this.months = months;
	}

	public static Season valueOf(int id) {
		for (Season i : values()) {
			if (i.id == id)
				return i;
		}

		return All;
	}

	public static Season monthOf(int month) {
		for (Season i : values()) {
			if (Arrays.binarySearch(i.months, month) >= 0)
				return i;
		}

		return All;
	}
}
